package test.com.sms.selenium.singlepoint.util;

import java.util.Set;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpOperationsSiteAuditPageUtil extends SeleniumPageUtil {

	public final static By OSA_LINK_NEW 			= By.id("SiteAudit1_btnNew");
	public final static By OSA_LINK_SROS 			= By.id("SiteAudit1_btnSROsWithoutSiteAudits");
	public final static By OSA_LINK_ADD 			= By.id("SiteAudit1_btnAddressesWithoutPM");
	public final static By OSA_SPAN_TITLE 			= By.id("SiteAudit1_lblHdr");
	public final static By OSA_LINK_QUICK 			= By.id("SiteAudit1_Menu_Chrome1_lblQuickLinks");
	public final static By OSA_LINK_LOGOUT 			= By.id("SiteAudit1_Menu_Chrome1_btnLogoutChrome");
	public final static By OSA_TD_SRO_ID 			= By.xpath("//*[@id='SiteAudit1_tblControls']/tbody/tr/td[1]/table/tbody/tr[1]/td[1]");
	public final static By OSA_INPUT_SRO_ID 		= By.id("SiteAudit1_txtSROID");
	public final static By OSA_TD_CUSTOMER 			= By.xpath("//*[@id='SiteAudit1_tblControls']/tbody/tr/td[1]/table/tbody/tr[2]/td[1]");
	public final static By OSA_SPAN_CUSTOMER 		= By.id("SiteAudit1_lblCustomer");
	public final static By OSA_TD_ADDRESS 			= By.xpath("//*[@id='SiteAudit1_tblControls']/tbody/tr/td[1]/table/tbody/tr[2]/td[3]");
	public final static By OSA_TD_CONTRACT 			= By.xpath("//*[@id='SiteAudit1_tblControls']/tbody/tr/td[1]/table/tbody/tr[3]/td[1]");
	public final static By OSA_SPAN_CONTRACT 		= By.id("SiteAudit1_lblContractID");
	public final static By OSA_TD_SRO_HOUSE 		= By.xpath("//*[@id='SiteAudit1_tblControls']/tbody/tr/td[1]/table/tbody/tr[4]/td[1]");
	public final static By OSA_SPAN_SRO_HOUSE 		= By.id("SiteAudit1_lblWarehouse");
	public final static By OSA_TD_LEAD 				= By.xpath("//*[@id='SiteAudit1_tblControls']/tbody/tr/td[1]/table/tbody/tr[5]/td[1]");
	public final static By OSA_SPAN_LEAD 			= By.id("SiteAudit1_txtAssignedToID");
	public final static By OSA_TD_CONFIG_MAS 		= By.xpath("//*[@id='SiteAudit1_tblControls']/tbody/tr/td[1]/table/tbody/tr[6]/td[1]");
	public final static By OSA_SPAN_CONFIG_MAS 		= By.id("SiteAudit1_lblConfigImportDate");
	public final static By OSA_TD_SRO_SITE_AUDIT 	= By.id("SiteAudit1_tdPrereqs");
	/**"SROs without SiteAudits" link page*/
	public final static By OSA_SROS_SPAN_RECS_NUMBER 	= By.xpath("//*[@id='ctl05_lblNumRecs']");
	public final static By OSA_SROS_TD_SRO_NUMBER 		= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[1]");
	public final static By OSA_SROS_TD_OPEN_DATE 		= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[2]");
	public final static By OSA_SROS_TD_STATUS_CODE 		= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[3]");
	public final static By OSA_SROS_TD_INCIDMENT_NUMER 	= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[4]");
	public final static By OSA_SROS_TD_CONTRACT_ID 		= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[5]");
	public final static By OSA_SROS_TD_LINE 			= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[6]");
	public final static By OSA_SROS_TD_WHSEID 			= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[7]");
	public final static By OSA_SROS_TD_SERIAL_NUMBER 	= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[8]");
	public final static By OSA_SROS_TD_CUS_ADD_NAME 	= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[9]");
	public final static By OSA_SROS_TD_ASSIGNED_TO 		= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[10]");
	public final static By OSA_SROS_TD_PROBLEMS 		= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[11]");
	/** "Addresses without PM" link page*/
	public final static By OSA_ADD_SPAN_RES_NUMBER 		= By.id("ctl05_lblNumRecs");
	public final static By OSA_ADD_CAPTION_PROBLEMS 	= By.xpath("//*[@id='tblResults']/caption");
	public final static By OSA_ADD_TD_CONTRACT_ID 		= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[1]");
	public final static By OSA_ADD_TD_ADD_NAME 			= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[2]");
	public final static By OSA_ADD_TD_ASSSETS 			= By.xpath("//*[@id='tblResults']/tbody/tr[2]/td[3]");
	// elements of pop-up list when entering sro ID
	public final static By OSA_DIV_SRO_ID = By.id("SiteAudit1_aceSROID_completionListElem"); 
	
	public static void enterOperationsSiteAuditPage(){
		SpHomePageUtil.enter();
		SpHomePageUtil.enterOperatioinsSiteAuditPage();
	}
	public static void waitForSiteAuditPageToLoad(){
		//site audit page in content area
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_CONTENT_NAME);
		SeleniumUtil.waitOnElements(new By[]{
				OSA_LINK_NEW,OSA_LINK_SROS,OSA_LINK_ADD,OSA_LINK_QUICK,OSA_INPUT_SRO_ID
			});
	}
	/**enter SROs without siteAudits page*/
	public static void enterSROS(){
		enterOperationsSiteAuditPage();
		Set<String> before = SeleniumUtil.getWindowHandles();
		SeleniumUtil.click(SeleniumUtil.getCachedElement(OSA_LINK_SROS));
		SeleniumUtil.waitForFixedMilliseconds(1000);
		// if browser prompt out a new window, switch to it
		SeleniumUtil.switchToPromptedWindow(before, SeleniumUtil.getWindowHandles());
		SeleniumUtil.selectDefaultContent();
	}
	/**enterAddresses without PM page*/
	public static void enterAddressesPM(){
		enterOperationsSiteAuditPage();
		Set<String> before = SeleniumUtil.getWindowHandles();
		SeleniumUtil.click(SeleniumUtil.getCachedElement(OSA_LINK_ADD));
		SeleniumUtil.waitForFixedMilliseconds(1000);
		// if browser prompt out a new window, switch to it
		SeleniumUtil.switchToPromptedWindow(before, SeleniumUtil.getWindowHandles());
		SeleniumUtil.selectDefaultContent();
	}
}
